-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix for console log URL #13
Conversation
6ba872f
to
e91deb6
Compare
This is how URL looks like http://www.awesomescreenshot.com/image/3162147/19df19d3a5cfe6a0c3d5a66e49698be8 in OpenShift console Note: URL host coming from ENV VAR |
@@ -162,7 +164,7 @@ protected void doRun() throws Exception { | |||
pollLoop(); | |||
} | |||
}; | |||
Timer.get().scheduleAtFixedRate(task, pollPeriodMs, pollPeriodMs, TimeUnit.MILLISECONDS); | |||
Timer.get().scheduleAtFixedRate(task, pollPeriodDelayMs, pollPeriodMs, TimeUnit.MILLISECONDS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this related to the issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's indirectly related. Recently similar issue has been observed in plugin behavior and the root cause of this issue was the frequency at which it polls the OpenShift API's.
IMHO, it would be better if this fix can go along with this issue. It may sound premature optimization though and not directly related.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, I'd recommend putting this into a dedicated commit with a proper commit message. Nothing stops you to address two issues within the same pull request, but for traceability, it makes sense to separate this.
IMO you should create an issue for this in this project referencing openshiftio/openshift.io#1648. Then you split this commit into to dedicated commits, each referencing its matching issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO, it would be better if this fix can go along with this issue.
Why?
I mean, I understand why we want this change in, but why does it have to go "along with this issue"?
In any case, please split the commits as Hardy suggested.
No test? What's about referencing the issue in the commit message? |
@hrishin the PR looks good to me, let me me know when you are happy with it we can merge it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please create dedicated issues and split commits. And what's about testing?
That said, feel free to ignore the review. It's not my call in the end. |
@hferentschik reverted polling changes. @rupalibehera can we merge it and test it if it looks good? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hrishin would you mind rebasing and squashing this? There no need for three commits and you literally want to remove that this polling change was ever in there.
Other than that, it looks ok. As I said, I recommend starting to adopt some issue referencing scheme in the commit messages, but you might want to discuss within the team first what you want to adopt.
Awesome with tests, btw.
public final org.junit.contrib.java.lang.system.EnvironmentVariables environmentVariables = new org.junit.contrib.java.lang.system.EnvironmentVariables(); | ||
|
||
@Test | ||
public void should_get_hostname_from_env_var() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:-) Yeah
} | ||
|
||
@Test | ||
public void should_get_hostname_from_openshift_service() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
} | ||
|
||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a newline missing. Does not matter for Java, but it would keep GitHub/git happy.
If you need help with the rebase, let me know. Happy to help. |
@hferentschik , I can rebase and merge while merging this PR from the github UI |
Sure, but @hrishin might want to adjust the commit messages or something. There is a difference in forcing a squash and doing a proper rebase of a pull request. |
it is late in India now, I am building the image with this fork and test if things work and then we can merge this one. |
@hrishin , tests are failing while compiling using |
@@ -258,7 +259,7 @@ private void upsertBuild(Run run, RunExt wfRunExt) { | |||
} | |||
|
|||
OpenShiftClient openShiftClient = getOpenShiftClient(); | |||
String rootUrl = OpenShiftUtils.getJenkinsURL(openShiftClient, namespace); | |||
String rootUrl = getHostName(openShiftClient, namespace); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I mentioned in PR 12, for a bugzilla we just got from a multi namespace customer, I will be making a change to use the jenkins pod namespace before the build namespace for this ... I'll tag you all in that PR.
I believe that should be fine with your env var override based on how this is constructed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool ... for cross referencing, here is the upstream pr: openshift#198
I'm sorry that's my bad :(, missed something to make it work. Now fixed the plugin loading issue to run the tests. Let's try to build an image and test it. @hferentschik |
ab36c06
to
a291aff
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I added some more comments. The docs are not quite right I think. AFAIU we are configuring a URL not a hostname. Two different things.
Could you also please re-craft the commit message. You are mixing subject and body. This does not look and read well. See for example https://chris.beams.io/posts/git-commit/. You want to have a subject line, followed by an empty line, followed by the actual change description which you already have.
openShiftServer.expect().get().withPath("/oapi/v1/namespaces/default/routes").andReturn(200, routeList).always(); | ||
return openShiftServer; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still missing a newline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but wondering why its so important?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not really important. It does not really matter, especially for Java. However, in some cases (languages, config file types) it does matters and hence GitHub flags it. Best practice is to have the newline.
README.md
Outdated
Configuration | ||
------------------------ | ||
Jenkins Build Log URL: | ||
* Plugin adds a annotation in Build resource metadata which contains URL to access Jenkins build logs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The plugin, instead of just plugin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an annotation
README.md
Outdated
------------------------ | ||
Jenkins Build Log URL: | ||
* Plugin adds a annotation in Build resource metadata which contains URL to access Jenkins build logs. | ||
By default host name for log URL comes from service running in OpenShift knows as "Jenkins". To override and configure this URL's host name, add an environment variable `JENKINS_ROOT_URL`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default host name for log URL -> By default, the Jenkins base URL for the build log is determined via the OpenShift route of the jenkins service. To override and configure this base URL, you can set the environment variable JENKINS_ROOT_URL
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
host name != (base) URL. What are we setting here? I take it is the base URL, right? Then please don't mix this up with hostname. These are two completely different things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for the docs, just needs some rework
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes its base URL
@hrishin @rupalibehera - so you don't have a CI building and testing pull requests? Why not? |
@hferentschik its kind of pitta :( to say this but unfortunately, there are no tests in place. Mostly we are planning to get rid of this fork so not sure of how to prioritize it. cc: @rupalibehera |
What do you mean? There are at the very least your tests, right? And it is not only about running tests, but also knowing that the project simply compiles.
Is this fork used right now? Do you have to cut some more releases of it? If so, it is imo a no-brainer. We are talking about adding a single YAML file and you get for example a Travis CI up and running. Time effort less than an hour. Create the issue, create a pull request with the Travis config, review, merge, done. |
https://docs.travis-ci.com/user/languages/java/ (note, I don't think this should be part of this pull request. Just saying it is trivial to enable and adds value with hardly any effort) |
I pulled in @hrishin code from his fork and created the .hpi and added it here https://github.com/rupalibehera/openshift-jenkins-s2i-config/tree/sync-plugin-idler/plugins and the Jenkins image is created a PR here fabric8io/openshift-jenkins-s2i-config#143, I am looking into the test failure. |
@@ -0,0 +1,81 @@ | |||
/** | |||
* Copyright (C) 2016 Red Hat, Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the wrong copyright yea
README.md
Outdated
Jenkins Build Log URL: | ||
* The plugin adds an annotation in Build resource metadata which contains URL to access Jenkins build logs. | ||
By default, the Jenkins base URL for the build log is determined via the OpenShift route of the jenkins service. To override and configure this base URL, you can set the environment variable `JENKINS_ROOT_URL`. | ||
This environment variable will get higher precedence than Jenkins service to determine base URL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"higher precedence" is a misnomer. Precedence already implies the order and that it has a higher rank in this order.
README.md
Outdated
Configuration | ||
------------------------ | ||
Jenkins Build Log URL: | ||
* The plugin adds an annotation in Build resource metadata which contains URL to access Jenkins build logs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This plugin adds an annotation to the OpenShift build configuration containing the Jenkins build log URL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs are still not quite right, but let's get this merged. We should strive to be concise when talking about the various technical aspects.
any plans to address the versioning? Can you not add a version string as well? How are the plugins picked up? By name or does it just load all plugins in the directory in which case one could just add the version.
You mean the test failure in the openshift-jenkins-s2i-config PR build? TBH, I have a hard time interpreting that it means.
ok, let us know how it goes |
You even have already a Travis config - https://github.com/fabric8io/jenkins-sync-plugin/blob/master/.travis.yml. It's just a matter of checking if it still runs the right target and making sure that pull requests are getting built. |
1. With introduction of Jenkins ideler/proxy have to fix the console URL generation With that higher precedence is given to ENV VAR (JENKINS_ROOT_URL) having proxy URL, otherwise, URL of Jenkins service if it does exist in OpenShift. This issue is fixed in BuildSyncRunListener.java 2. Added the unit test for this fix : BuildSyncRunListenerTest.java 3. Fixed test execution issue : Upgraded <artifactId>credentials</artifactId> dependency version 4. Updated README.md with this URL configuration section
@rupalibehera what's the outcome, did all go well? Could you test and verify this patch? |
@hferentschik , sorry forgot to update it here the testing of the image went well and everything from the Jenkins perspective looks good, but we were trying to figure out the fix for fabric8-services/fabric8-tenant#528, I believe that is fixed by @chmouel https://github.com/fabric8-services/fabric8-tenant/pull/529/files and fabric8-services/fabric8-tenant-jenkins#65 |
@hrishin @hferentschik , I am merging this PR as testing went well I will update the image with this binary and update the PR fabric8io/openshift-jenkins-s2i-config#143 |
With that higher precedence is given to ENV VAR having proxy URL, otherwise, URL of Jenkins service if it does exist in OpenShift
#11